package com.xukai.springboot.service.patient;

import com.xukai.springboot.datalayer.patient.PatientMapper;
import com.xukai.springboot.entity.patient.t_patient_wechat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 患者微信信息
 */
@Service
public class PatientWechatService {
    /**
     *
     */
    @Autowired
    public PatientMapper patientMapper;

    /**
     * 新建患者微信信息
     *
     * @return
     */
    public t_patient_wechat CreatePatientWechat(String openID, String nickeName, String province, int sex, String city, String country, String headimgUrl, String unionid) {

        t_patient_wechat data = new t_patient_wechat();
        data.setCity(city);
        data.setCountry(country);
        data.setHeadimgurl(headimgUrl);
        data.setNickName(nickeName);
        data.setOpenID(openID);
        data.setProvince(province);
        data.setSex(sex);
        data.setState(0);
        data.setUnionid(unionid);
        data.setCreateTime(new Date());
        patientMapper.CreatePatientWechat(data);
        return data;
    }

    /**
     * 修改患者微信信息
     */
    public void UpdatePatientWechat(String openID, String nickName, int sex, String province, String city,
                                    String country, String headimgurl) {
        patientMapper.UpdatePatientWeChat(openID, nickName, sex, province, city, country, headimgurl);
    }

    /**
     * 修改患者微信信息状态
     *
     * @param id
     * @param state
     */
    public void UpdatePatientWechatState(int id, int state) {

        patientMapper.UpdatePatientWeChatState(id, state);
    }
}
